import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    newsList: []
  },
  getters:{
    getNewsById: (state) => (id) => {
      console.log(id)
      console.log(state.newsList)
      return state.newsList.find(news => news.docid === id)
    }
  },
  mutations: {
    SET_NEWS_LIST(store, newsList){
      store.newsList = newsList
    }
  },
  actions: {

  }
})
